public class code1 {
    public int uniquePaths(int m, int n) {
        //细节1.多开一个行和一列：方便初始化
        int[][] dp = new int[m+1][n+1];//dp[i][j]:到i,j位置有多少条路径
        dp[0][1] = 1;//或者dp[1][0]=1

        for (int i = 1; i <=m; i++) {
            for (int j = 1; j <=n ; j++) {
                dp[i][j] = dp[i-1][j] + dp[i][j-1];//分解为向下走和向右走的路径之和
            }
        }

        return dp[m][n];
    }
}
